package ai.leinao.notify.core;

import ai.leinao.notify.core.enums.NotifyType;
import ai.leinao.notify.core.provider.NotifierProvider;
import cn.hutool.core.collection.CollUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Map;

/**
 * 通知配置属性
 *
 * @author zhong.wang
 * @date 2025/7/7
 */
@Getter
@Setter
public class NotifyProperties implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private String id;

    /**
     * 通知类型
     */
    private NotifyType notifyType;

    /**
     * 供应商
     */
    private String provider;

    /**
     * 名称
     */
    private String name;

    /**
     * 配置
     * @see NotifierProvider
     */
    private Map<String, Object> configuration;

    /**
     * 获取字符串
     * @param key
     * @param defaultValue
     * @return
     */
    public String getString(String key, String defaultValue){
        if(CollUtil.isEmpty( configuration) || !configuration.containsKey(key)) {
            return defaultValue;
        }
        return String.valueOf(configuration.get(key));
    }
}
